'This allows programmer-access to the camera object
Property Get Camera() As clsCamera
Set Camera = mCamera
End Property
'Returns a texture when given the reference name of an existing texture
'This function will return NOTHING if the reference name provided does not exist
Public Function GetTexture(strTexture As String) As Direct3DTexture8
On Error GoTo error_h
If IsInCollection(colTextures, strTexture) Then
Set GetTexture = colTextures(strTexture)
Else
Set GetTexture = Nothing
End If
Exit Function
error_h:
Select Case ErrMsg(Err, "jDXEngine.GetTexture(" & strTexture & ")")
Case vbRetry
Resume
Case vbIgnore
Resume Next
Case Else
Exit Function
End Select
End Function
'This function will determine if an item with a specific key exists within a collection
Private Function IsInCollection(collection As collection, strKey As String) As Boolean
On Error GoTo error_h
On Error Resume Next
Dim X As Direct3DTexture8
Set X = collection(strKey)
If Err Then
Err.Clear
IsInCollection = False
Else
IsInCollection = True
End If
Exit Function
error_h:
Select Case ErrMsg(Err, "jDXEngine.IsInCollection")
Case vbRetry
Resume
Case vbIgnore
Resume Next
Case Else
Exit Function
End Select
End Function
'r=red value(0-255),g=green,b=blue
Public Function jRGB(r As Integer, g As Integer, b As Integer) As Long
On Error GoTo error_h
'I've noticed when working with DX8 that the long color code values it uses
'are exactly the same as VB's RGB() function except that the R and B values
'are transposed, so I wrote this little helper function to help out with that.
jRGB = RGB(b, g, r)
Exit Function
error_h:
Select Case ErrMsg(Err, "jDXEngine.DXRGB(" & r & "," & g & "," & b & ")")
Case vbRetry
Resume
Case vbIgnore
Resume Next
Case Else
Exit Function
End Select
End Function
Public Sub EndRender()
On Error GoTo error_h
'All we need to do to stop rendering is set this little variable here to false. :)
bRunning = False
Exit Sub
error_h:
Select Case ErrMsg(Err, "jDXEngine.EndRender")
Case vbRetry
Resume
Case vbIgnore
Resume Next
Case Else
Exit Sub
End Select
End Sub
'hWnd = the handle to the window that you want to draw in (i THINK it can be anything with a hWnd property, but don't quote me on that)
'HardwareDevice = true if you want to use a 3d accelorator card... false if not
'vtrCamPos = a vector desribing the initial position of the camera
'lngBackColor = the background color when rendering
'blnUseLighting = True to enable lighting
'blnCullCCW = True to enable back-face removal
Public Function InitWindowed(hWnd As Long, HardwareDevice As Boolean, vtrCamPos As D3DVECTOR, lngBackColor As Long, blnUseLighting As Boolean, blnCullCCW As Boolean) As Boolean
On Error GoTo error_h
'Boolean values default to false, but just to be safe...
InitWindowed = False
'Declare variables to store display information
Dim d3dpp As D3DPRESENT_PARAMETERS
Dim DispMode As D3DDISPLAYMODE
'Create the main 3 objects (D3DX8 is NOT one of the main 3... D3DDevice is the 3rd, but we must configure it first)